<template>
	<!-- 确认订单信息里的商品信息组件 -->
	<view class="order_goods_box bgc_fff" v-for="order in orders.list">
		<view class="color_999 font_24 m_b_4 text_nowrap">订单号：{{ order.orderToken }}</view>
		<view class="flex">
			<image v-if="order.orderItems[0].skuPic == null" class="item_goods_img m_r_16"
				src="https://img0.baidu.com/it/u=1120845135,2895795328&fm=253&fmt=auto&app=138&f=JPEG?w=400&h=400" mode="">
			</image>
			<image v-else class="item_goods_img m_r_16" :src="order.orderItems[0].skuPic" mode="">
			</image>
			<view class="flex-fitem">
				<view class="m_b_8 flex-aic flexr-jsb">
					<text class="color_333 font_24 text_nowrap" style="max-width: 380rpx;">{{ order.orderItems[0].spuName
					}}</text>
					<text class="color_333 font_28">￥{{ order.orderItems[0].skuPrice }}</text>
				</view>
				<view class="color_999 font_24 m_b_4 text_nowrap" style="max-width: 560rpx;">{{ order.orderItems[0].skuName
				}}</view>
			</view>
		</view>
		<view class="flex-aic flexr-jfe">
			<lyz-input-num v-model:num="order.orderItems[0].skuQuantity"></lyz-input-num>
		</view>
	</view>
</template>

<script setup>
import { onShow, onHide, onLoad } from "@dcloudio/uni-app"
import { reactive,computed, watch } from "vue";
import http from '../../../common/http.js'
const emit = defineEmits(['total'])
const orders = reactive({ list: [] })
onShow(() => {
	orders.list = []
	let newOrder = uni.getStorageSync("new-order")
	// uni.removeStorageSync('new-order');
	newOrder.forEach((item) => {
		http({
			url: `/orders-api/app-api/orders/_confirm`,
			method: "post"
		}, { skuId: item.skuId, count: item.count }).then(res => {
			orders.list.push(res.data)
			console.log(res.data);
		})
	})
})
 watch(orders,() => {
	let total = 0
	orders.list.forEach((item) => {
			total += item.orderItems[0].skuPrice * item.orderItems[0].skuQuantity
	})
	emit("total",total,orders.list)
})

</script>

<style lang="scss" scoped>
.item_goods_img {
	width: 108rpx;
	height: 108rpx;
	border-radius: 2rpx;
	overflow: hidden;
}

.order_goods_box {
	padding: 24rpx 32rpx;
}
</style>